package com.yjf.ljr.parser;

import java.util.ArrayList;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

import com.yjf.ljr.model.ResponseData;

public class HighSalaryParser extends BaseParser {

	private HighSalaryInfo mHighSalaryInfo;
	private String mCount;

	@Override
	public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
		if (localName.equals("hspjobs")) {
			super.mRespObj.dataList = new ArrayList<ResponseData>();
		} else if (localName.equals("hspjob")) {
			mHighSalaryInfo = new HighSalaryInfo();
		}
	}

	@Override
	public void endElement(String uri, String localName, String qName) throws SAXException {
		if (localName.equals("code")) {
			super.mRespObj.code = super.mBuf.toString().trim();
			super.mBuf.setLength(0);
		} else if (localName.equals("msg")) {
			super.mRespObj.msg = super.mBuf.toString().trim();
			super.mBuf.setLength(0);
		} else if (localName.equals("id")) {
			mHighSalaryInfo.id = super.mBuf.toString().trim();
			super.mBuf.setLength(0);
		} else if (localName.equals("count")) {	// 条数
			mCount = super.mBuf.toString().trim();
			super.mBuf.setLength(0);
		} else if (localName.equals("id")) {
			mHighSalaryInfo.id = super.mBuf.toString().trim();
			super.mBuf.setLength(0);
		} else if (localName.equals("entname")) {
			mHighSalaryInfo.entname = super.mBuf.toString().trim();
			super.mBuf.setLength(0);
		} else if (localName.equals("jobname")) {
			mHighSalaryInfo.jobname = super.mBuf.toString().trim();
			super.mBuf.setLength(0);
		} else if (localName.equals("minsalary")) {
			mHighSalaryInfo.minsalary = super.mBuf.toString().trim();
			super.mBuf.setLength(0);
		} else if (localName.equals("maxsalary")) {
			mHighSalaryInfo.maxsalary = super.mBuf.toString().trim();
			super.mBuf.setLength(0);
		} else if (localName.equals("workmodecode")) {
			mHighSalaryInfo.workmodecode = super.mBuf.toString().trim();
			super.mBuf.setLength(0);
		} else if (localName.equals("publishtime")) {
			mHighSalaryInfo.publishtime = super.mBuf.toString().trim();
			super.mBuf.setLength(0);
		} else if (localName.equals("hspjob")) {	// add to list
			super.mRespObj.dataList.add(mHighSalaryInfo);
			super.mBuf.setLength(0);
		}
	}

	public String getCount() {
		return mCount;
	}
	
	public class HighSalaryInfo extends ResponseData {
		public String id;
		public String entname; // 企业名称
		public String jobname; // 职位
		public String minsalary; // 薪水
		public String maxsalary; // 薪水
		public String workmodecode; // 工作类型
		public String publishtime; //发布时间
	}

}
